﻿<template>
  <div>
    <a-card :bordered="false" :bodyStyle="tstyle">

      <div class="table-page-search-wrapper" v-if="hasPerm('NitfOrg002aInput:page')">
        <a-form layout="inline">
          <a-row :gutter="48">
            <a-col :md="8" :sm="24">
              <a-form-item label="HIS 系统跟踪号(唯一) ">
                <a-input v-model="queryParam.orgTraceNo" allow-clear placeholder="请输入HIS 系统跟踪号(唯一) "/>
              </a-form-item>
            </a-col>
            <a-col :md="8" :sm="24">
              <a-form-item label="就诊凭证类型固定为 02 身份证 ">
                <a-input v-model="queryParam.mdtrtCertType" allow-clear placeholder="请输入就诊凭证类型固定为 02 身份证 "/>
              </a-form-item>
            </a-col><template v-if="advanced">
              <a-col :md="8" :sm="24">
                <a-form-item label="就诊凭证编号 ">
                  <a-input v-model="queryParam.mdtrtCertNo" allow-clear placeholder="请输入就诊凭证编号 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="证件号 ">
                  <a-input v-model="queryParam.certNo" allow-clear placeholder="请输入证件号 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="患者院内证件号 ">
                  <a-input v-model="queryParam.hisCustId" allow-clear placeholder="请输入患者院内证件号 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="患者院内证件类 ">
                  <a-input v-model="queryParam.hisCustType" allow-clear placeholder="请输入患者院内证件类 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="机构编号(国标医院编码)机构的国家统一编码 ">
                  <a-input v-model="queryParam.orgCode" allow-clear placeholder="请输入机构编号(国标医院编码)机构的国家统一编码 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="分院编号分机构编号，以用来区分分院或者基卫，如果为空则默认为本院该字典需由定点机构提供 ">
                  <a-input v-model="queryParam.subOrgCode" allow-clear placeholder="请输入分院编号分机构编号，以用来区分分院或者基卫，如果为空则默认为本院该字典需由定点机构提供 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="账户类型:01:门诊账户02:住院账户参考账户类型字典 ">
                  <a-input v-model="queryParam.accountType" allow-clear placeholder="请输入账户类型:01:门诊账户02:住院账户参考账户类型字典 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="查询开始日期可空,处方日期格式：yyyy-MM-dd ">
                  <a-input v-model="queryParam.beginDate" allow-clear placeholder="请输入查询开始日期可空,处方日期格式：yyyy-MM-dd "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="查询截止日期可空,处方日期格式：yyyy-MM-dd ">
                  <a-input v-model="queryParam.endDate" allow-clear placeholder="请输入查询截止日期可空,处方日期格式：yyyy-MM-dd "/>
                </a-form-item>
              </a-col>            </template>

            <a-col :md="8" :sm="24" >
              <span class="table-page-search-submitButtons">
                <a-button type="primary" @click="$refs.table.refresh(true)" >查询</a-button>
                <a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
                <a @click="toggleAdvanced" style="margin-left: 8px"> {{ advanced ? '收起' : '展开' }}
                  <a-icon :type="advanced ? 'up' : 'down'"/>
                </a>
              </span>
            </a-col>

          </a-row>
        </a-form>
      </div>
    </a-card>
    <a-card :bordered="false">
      <s-table
        ref="table"
        :columns="columns"
        :data="loadData"
        :alert="true"
        :rowKey="(record) => record.iD"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }">
        <template class="table-operator" slot="operator" v-if="hasPerm('NitfOrg002aInput:add')" >
          <a-button type="primary" v-if="hasPerm('NitfOrg002aInput:add')" icon="plus" @click="$refs.addForm.add()">新增查询费用列表</a-button>
        </template>
        <span slot="action" slot-scope="text, record">
          <a v-if="hasPerm('NitfOrg002aInput:edit')" @click="$refs.editForm.edit(record)">编辑</a>
          <a-divider type="vertical" v-if="hasPerm('NitfOrg002aInput:edit') & hasPerm('NitfOrg002aInput:delete')"/>
          <a-popconfirm v-if="hasPerm('NitfOrg002aInput:delete')" placement="topRight" title="确认删除？" @confirm="() => NitfOrg002aInputDelete(record)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </s-table>
      <add-form ref="addForm" @ok="handleOk" />
      <edit-form ref="editForm" @ok="handleOk" />
    </a-card>
  </div>
</template>
<script>
  import { STable } from '@/components'
  import { NitfOrg002aInputPage, NitfOrg002aInputDelete } from '@/api/modular/main/NitfOrg002aInputManage'
  import addForm from './addForm.vue'
  import editForm from './editForm.vue'
  export default {
    components: {
      STable,
      addForm,
      editForm
    },
    data () {
      return {
        advanced: false, // 高级搜索 展开/关闭
        queryParam: {},
        columns: [
          {
            title: 'HIS 系统跟踪号(唯一) ',
            align: 'center',
            dataIndex: 'orgTraceNo'
          },
          {
            title: '就诊凭证类型固定为 02 身份证 ',
            align: 'center',
            dataIndex: 'mdtrtCertType'
          },
          {
            title: '就诊凭证编号 ',
            align: 'center',
            dataIndex: 'mdtrtCertNo'
          },
          {
            title: '证件号 ',
            align: 'center',
            dataIndex: 'certNo'
          },
          {
            title: '患者院内证件号 ',
            align: 'center',
            dataIndex: 'hisCustId'
          },
          {
            title: '患者院内证件类 ',
            align: 'center',
            dataIndex: 'hisCustType'
          },
          {
            title: '机构编号(国标医院编码)机构的国家统一编码 ',
            align: 'center',
            dataIndex: 'orgCode'
          },
          {
            title: '分院编号分机构编号，以用来区分分院或者基卫，如果为空则默认为本院该字典需由定点机构提供 ',
            align: 'center',
            dataIndex: 'subOrgCode'
          },
          {
            title: '账户类型:01:门诊账户02:住院账户参考账户类型字典 ',
            align: 'center',
            dataIndex: 'accountType'
          },
          {
            title: '查询开始日期可空,处方日期格式：yyyy-MM-dd ',
            align: 'center',
            dataIndex: 'beginDate'
          },
          {
            title: '查询截止日期可空,处方日期格式：yyyy-MM-dd ',
            align: 'center',
            dataIndex: 'endDate'
          }
        ],
        tstyle: { 'padding-bottom': '0px', 'margin-bottom': '10px' },
        // 加载数据方法 必须为 Promise 对象
        loadData: parameter => {
          return NitfOrg002aInputPage(Object.assign(parameter, this.queryParam)).then((res) => {
            return res.data
          })
        },
        selectedRowKeys: [],
        selectedRows: []
      }
    },
    created () {
      if (this.hasPerm('NitfOrg002aInput:edit') || this.hasPerm('NitfOrg002aInput:delete')) {
        this.columns.push({
          title: '操作',
          width: '150px',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' }
        })
      }
    },
    methods: {
      /**
       * 查询参数组装
       */
      switchingDate () {
        const obj = JSON.parse(JSON.stringify(this.queryParam))
        return obj
      },
      NitfOrg002aInputDelete (record) {
        NitfOrg002aInputDelete(record).then((res) => {
          if (res.success) {
            this.$message.success('删除成功')
            this.$refs.table.refresh()
          } else {
            this.$message.error('删除失败') // + res.message
          }
        })
      },
      toggleAdvanced () {
        this.advanced = !this.advanced
      },
      handleOk () {
        this.$refs.table.refresh()
      },
      onSelectChange (selectedRowKeys, selectedRows) {
        this.selectedRowKeys = selectedRowKeys
        this.selectedRows = selectedRows
      }
    }
  }
</script>
<style lang="less">
  .table-operator {
    margin-bottom: 18px;
  }
  button {
    margin-right: 8px;
  }
</style>
